package org.activequant.dao.hibernate.types;

import org.activequant.core.types.Expiry;

/**
 * Hibernate helper to convert Expiry to/from SQL type.
 * <br>
 * ExpiryType extends SimpleType. Holds the following inherited variable:
 * <ul>
 * <li>sqlTypes(int[])</li>
 * </ul>
 * <b>History:</b><br>
 *  - [Nov 6, 2007] Created (Mike Kroutikov)<br>
 *
 *  @author Mike Kroutikov
 */
public class ExpiryType extends SimpleType {
	/**
	 * returns <code>Expiry.class</code>
	 */
	public Class<Expiry> returnedClass() {
		return Expiry.class;
	}
	/**
	 * returns the stamp(TimeStamp) of the given obj(Expiry) as a String formatted with the "yyyyMMdd" format
	 */
	@Override
	protected String format(Object obj) {
		return ((Expiry) obj).toString();
	}
	/**
	 * creates and returns an Expiry whose stamp(TimeStamp) is parsed from the given val(String) (requires yyyyMMdd format)
	 */
	@Override
	protected Object parse(String val) {
		return new Expiry(val);
	}
}
